package com.File;

import java.io.*;

//BufferedOutputStream和BufferedInPutStream的使用

public class BufferedCopy02 {
    public static void main(String[] args) {
        String srcFilePath = "d:\\tx.jpg";
        String distFilePath = "d:\\tx01.jpg";
        BufferedInputStream bis = null;
        BufferedOutputStream bos = null;
        try {
            bis = new BufferedInputStream(new FileInputStream(srcFilePath));
            bos = new BufferedOutputStream(new FileOutputStream(distFilePath));
            byte[] buf = new byte[1024];
            int readLin = 0;
            while ((readLin = bis.read(buf)) != -1) {
                bos.write(buf, 0, readLin);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (bis != null) {
                    bis.close();
                }
                if (bos != null) {
                    bos.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

